export const shuffle = <T>(arr: T[]): T[] => {
	return [...arr].sort(() => 0.5 - Math.random());
};
export const buildUrl = (url: string, params: { title: string }) => {
	let urlWithParams = url;
	Object.entries(params).forEach(([key, value], i) => {
		const sign = !i ? '?' : '&';
		urlWithParams += `${sign}${key}=${value}`;
	});
	return urlWithParams;
};

export const sumBy = (arr: number[]): number =>
	arr.reduce((prev, cur) => prev + cur, 0);
